part of 'widgets.dart';

class VanRotationWidget extends StatefulWidget {
  final Widget? child;

  final Duration duration;
  final Curve curve;

  const VanRotationWidget({super.key, this.child, required this.duration, this.curve = Curves.easeInOut});

  @override
  State<VanRotationWidget> createState() => _VanRotationWidgetState();
}

class _VanRotationWidgetState extends State<VanRotationWidget> with TickerProviderStateMixin {
  late final AnimationController _controller;
  late final Animation<double> _animation;

  @override
  void initState() {
    super.initState();
    _controller = AnimationController(vsync: this, duration: widget.duration)..repeat();
    _animation = CurvedAnimation(parent: _controller, curve: widget.curve);
  }

  @override
  void dispose() {
    _controller.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return RotationTransition(turns: _animation, child: widget.child);
  }
}